<?php
namespace app\common\validate;

use think\Validate;

class GoodsValidate extends Validate
{
    protected $rule =   [
        'id'                       => 'require|number',
        'page|页数'                => 'require|number',
        'limit|条数'               => 'require|number',
        'name|名称'                => 'require|length:1,200',
        'type|类型'                => 'require|gt:0',
        'cate_id|分类 '            => 'require|gt:0',
        'describe|描述'            => 'require|length:1,200',
        'price|价格'               => 'require',
        'price_origin|原价'        => 'require',
        'price_brokerage|佣金价格' => 'requireIf:type,2',
        'brokerage_ratio|返利佣金' => 'requireIf:type,2',
        'point_ratio|返利积分'     => 'requireIf:type,4',
        'money_red|返利红包'       => 'requireIf:type,3',
        'small_img|展示图片'       => 'require|file',
    ];
    
    protected $scene = [
        /** admin */
        'show'     => ['id'],
        'list'     => ['page', 'limit'],
        'add'      => ['name', 'type', 'cate_id', 'describe', 'price', 'price_origin', 'price_brokerage', 'brokerage_ratio', 'point_ratio', 'money_red', 'small_img'],
        'edit'     => ['id', 'name', 'type', 'cate_id', 'describe', 'price', 'price_origin', 'price_brokerage', 'brokerage_ratio', 'point_ratio', 'money_red'],
        'edit_img' => ['id', 'name', 'type', 'cate_id', 'describe', 'price', 'price_origin', 'price_brokerage', 'brokerage_ratio', 'point_ratio', 'money_red', 'small_img'],
    ];
}